#pragma once
#include "ui_kit/ui_kit.h"
//#include "../../macro_data_manager/macro_data_base.h"
//#include "../../macro_tree_manager/macro_tree_struct.h"
//#include "SSMain\views\template_db_table\db_table_data_manager\db_table_data_base.h"

//struct KnowledgeItem{
//	std::string id;
//	std::string collectionCode;
//	std::string collectionName;
//};
typedef std::function<void(std::string parentGjkCode, std::vector<std::string> vecGjkCode, std::string fileId)> UploadMacroDataParseFileCallback;

class UploadUrlBox;
class UploadParseFileForm : public ui_comp::WindowEx, public ui::IGridHost
{
public:
	UploadParseFileForm();
	virtual ~UploadParseFileForm(){
	};

	virtual std::wstring GetSkinFolder() override{ return L"sdp/upload_parse_file_form"; };
	virtual std::wstring GetSkinFile() override{ return L"upload_parse_file_form.xml"; };
	virtual std::wstring GetWindowClassName() const override { return L"UploadParseFileForm"; };
	virtual ui::Control* CreateControl(const std::wstring& sClass);

	virtual void InitWindow() override;
	virtual void Close(UINT nRet = IDOK) override;
	virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) override;

	//void SetInitData(std::string parentGjkCode, std::vector<std::string>& vecGjkCode, std::string indexDate, MacroTreeType macroTreeType);
	void SetLabelStatusText(std::wstring sText, bool showLoading = false);
	void InitComboKnowledge();
	void InitComboTag();

	void RegisterUploadMacroDataParseFileCallback(const UploadMacroDataParseFileCallback& cb){ m_cb = cb; };
	
	void LockUI(bool bLock);
	void DoUploadPDF(const std::vector<std::string>& vecFile, const std::string& parentGjkCode, const std::vector<std::string>& vecGjkCode, const std::vector<std::string>& vecTag, const std::string& publishDate, const std::string& collectionId);
	void DoUploadOnlineDisk(const std::vector<std::string>& vecFile, const std::vector<std::pair<std::string, std::string>>& vecUrl,  std::string& parentGjkCode, const std::vector<std::string>& vecGjkCode, const std::vector<std::string>& vecTag, const std::string& publishDate, const std::string& collectionId);

	bool OnBtnFileClicked(ui::EventArgs* arg);
	bool OnBtnUploadClicked(ui::EventArgs* arg);
	bool OnBtnAddKnowledge(ui::EventArgs* arg);
protected:
	void OnMessageQueryKnowledgeList(WPARAM wParam, LPARAM lParam);
	void OnMessageAddKnowledge(WPARAM wParam, LPARAM lParam);
	void OnMessageQueryAiTagList(WPARAM wParam, LPARAM lParam);
	void OnMessageUploadParseFile(WPARAM wParam, LPARAM lParam);
public:
	static const std::wstring kClassName;
private:
	ui::Storage	* m_pStorFile{ nullptr };
	ui::FilterCombo* m_pComboKnowledge{ nullptr };
	UploadUrlBox* m_pListUrl{ nullptr };
	ui::MutilCombo	* m_pComboTag{ nullptr };
	ui::RichEdit	* m_pReDate{ nullptr };
	ui::Button		* m_pBtnFile{ nullptr };
	ui::Button		* m_pBtnUpload{ nullptr };
	ui::Button		* m_pBtnAddKnowledge{ nullptr };

	ui::Label		* m_pLabelStatus{ nullptr };

	std::vector<std::string> m_vecGjkCode;
	std::string m_parentGjkCode;
	//MacroTreeType m_macroTreeType{ MacroTreeType::MacroTreeType_Data };
	static std::string m_indexDate;

	UploadMacroDataParseFileCallback m_cb;
};



